package com.biqee.dao.impl;

import java.util.List;

import com.biqee.dao.TbItemDAO;
import com.biqee.dao.base.BaseDAOImpl;
import com.biqee.model.common.PageInfoObject;
import com.biqee.model.db.TbItem;

public class TbItemDAOImpl extends BaseDAOImpl implements TbItemDAO {

	@Override
	public Integer create(TbItem tbItem) {
		if(tbItem == null) {
			throw new RuntimeException("tbItem should not be null");
		}
		
		return (Integer)getSqlMapClientTemplate().insert(getRealSqlId("create"), tbItem);
	}

	@Override
	public int update(TbItem tbItem) {
		return getSqlMapClientTemplate().update(getRealSqlId("update"), tbItem);
	}

	@Override
	public TbItem read(int id) {
		return (TbItem)getSqlMapClientTemplate().queryForObject(getRealSqlId("read"), id);
	}

	@Override
	public TbItem readByTbItemId(String tbItemId) {
		return (TbItem)getSqlMapClientTemplate().queryForObject(getRealSqlId("readByTbItemId"), tbItemId);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<TbItem> listByPage(PageInfoObject page) {
		return this.getSqlMapClientTemplate().queryForList(getRealSqlId("listByPage"), page);
	}

}